import { ref } from "vue"

const clone = (val: any) => {
    if (val === null || typeof val !== 'object') return val
    return JSON.parse(JSON.stringify(val))
}
const resetAble = <T>(val: T) => {
    const initData = clone(val)
    const data = ref(val)
    const reset = () => {
        data.value = clone(initData)
    }
    return { data, reset }
}
export { resetAble } 